﻿using System;
using System.Data;
using System.Text;
using MySql.Data.MySqlClient;
using Maticsoft.DBUtility;//Please add references
namespace hcrainMvc.DAL
{
	/// <summary>
	/// 数据访问类:ym_web_lf
	/// </summary>
	public partial class ym_web_lf
	{
		public ym_web_lf()
		{}
		#region  BasicMethod



		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(hcrainMvc.Model.ym_web_lf model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into ym_web_lf(");
			strSql.Append("mlfid,msmid,ldid,url,项目楼栋情况,座号,户型,合同号,发展商叫价,楼层,房号,用途,预售查丈建筑面积,预售查丈户内面积,预售查丈分摊面积,竣工查丈户内面积,竣工查丈分摊面积,竣工查丈建筑面积)");
			strSql.Append(" values (");
			strSql.Append("@mlfid,@msmid,@ldid,@url,@项目楼栋情况,@座号,@户型,@合同号,@发展商叫价,@楼层,@房号,@用途,@预售查丈建筑面积,@预售查丈户内面积,@预售查丈分摊面积,@竣工查丈户内面积,@竣工查丈分摊面积,@竣工查丈建筑面积)");
			MySqlParameter[] parameters = {
					new MySqlParameter("@mlfid", MySqlDbType.Double),
					new MySqlParameter("@msmid", MySqlDbType.Double),
					new MySqlParameter("@ldid", MySqlDbType.Double),
					new MySqlParameter("@url", MySqlDbType.VarChar,255),
					new MySqlParameter("@项目楼栋情况", MySqlDbType.VarChar,255),
					new MySqlParameter("@座号", MySqlDbType.VarChar,255),
					new MySqlParameter("@户型", MySqlDbType.VarChar,255),
					new MySqlParameter("@合同号", MySqlDbType.VarChar,255),
					new MySqlParameter("@发展商叫价", MySqlDbType.VarChar,255),
					new MySqlParameter("@楼层", MySqlDbType.VarChar,255),
					new MySqlParameter("@房号", MySqlDbType.VarChar,255),
					new MySqlParameter("@用途", MySqlDbType.VarChar,255),
					new MySqlParameter("@预售查丈建筑面积", MySqlDbType.VarChar,255),
					new MySqlParameter("@预售查丈户内面积", MySqlDbType.VarChar,255),
					new MySqlParameter("@预售查丈分摊面积", MySqlDbType.VarChar,255),
					new MySqlParameter("@竣工查丈户内面积", MySqlDbType.VarChar,255),
					new MySqlParameter("@竣工查丈分摊面积", MySqlDbType.VarChar,255),
					new MySqlParameter("@竣工查丈建筑面积", MySqlDbType.VarChar,255)};
			parameters[0].Value = model.mlfid;
			parameters[1].Value = model.msmid;
			parameters[2].Value = model.ldid;
			parameters[3].Value = model.url;
			parameters[4].Value = model.项目楼栋情况;
			parameters[5].Value = model.座号;
			parameters[6].Value = model.户型;
			parameters[7].Value = model.合同号;
			parameters[8].Value = model.发展商叫价;
			parameters[9].Value = model.楼层;
			parameters[10].Value = model.房号;
			parameters[11].Value = model.用途;
			parameters[12].Value = model.预售查丈建筑面积;
			parameters[13].Value = model.预售查丈户内面积;
			parameters[14].Value = model.预售查丈分摊面积;
			parameters[15].Value = model.竣工查丈户内面积;
			parameters[16].Value = model.竣工查丈分摊面积;
			parameters[17].Value = model.竣工查丈建筑面积;

			int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(hcrainMvc.Model.ym_web_lf model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update ym_web_lf set ");
			strSql.Append("mlfid=@mlfid,");
			strSql.Append("msmid=@msmid,");
			strSql.Append("ldid=@ldid,");
			strSql.Append("url=@url,");
			strSql.Append("项目楼栋情况=@项目楼栋情况,");
			strSql.Append("座号=@座号,");
			strSql.Append("户型=@户型,");
			strSql.Append("合同号=@合同号,");
			strSql.Append("发展商叫价=@发展商叫价,");
			strSql.Append("楼层=@楼层,");
			strSql.Append("房号=@房号,");
			strSql.Append("用途=@用途,");
			strSql.Append("预售查丈建筑面积=@预售查丈建筑面积,");
			strSql.Append("预售查丈户内面积=@预售查丈户内面积,");
			strSql.Append("预售查丈分摊面积=@预售查丈分摊面积,");
			strSql.Append("竣工查丈户内面积=@竣工查丈户内面积,");
			strSql.Append("竣工查丈分摊面积=@竣工查丈分摊面积,");
			strSql.Append("竣工查丈建筑面积=@竣工查丈建筑面积");
			strSql.Append(" where ");
			MySqlParameter[] parameters = {
					new MySqlParameter("@mlfid", MySqlDbType.Double),
					new MySqlParameter("@msmid", MySqlDbType.Double),
					new MySqlParameter("@ldid", MySqlDbType.Double),
					new MySqlParameter("@url", MySqlDbType.VarChar,255),
					new MySqlParameter("@项目楼栋情况", MySqlDbType.VarChar,255),
					new MySqlParameter("@座号", MySqlDbType.VarChar,255),
					new MySqlParameter("@户型", MySqlDbType.VarChar,255),
					new MySqlParameter("@合同号", MySqlDbType.VarChar,255),
					new MySqlParameter("@发展商叫价", MySqlDbType.VarChar,255),
					new MySqlParameter("@楼层", MySqlDbType.VarChar,255),
					new MySqlParameter("@房号", MySqlDbType.VarChar,255),
					new MySqlParameter("@用途", MySqlDbType.VarChar,255),
					new MySqlParameter("@预售查丈建筑面积", MySqlDbType.VarChar,255),
					new MySqlParameter("@预售查丈户内面积", MySqlDbType.VarChar,255),
					new MySqlParameter("@预售查丈分摊面积", MySqlDbType.VarChar,255),
					new MySqlParameter("@竣工查丈户内面积", MySqlDbType.VarChar,255),
					new MySqlParameter("@竣工查丈分摊面积", MySqlDbType.VarChar,255),
					new MySqlParameter("@竣工查丈建筑面积", MySqlDbType.VarChar,255)};
			parameters[0].Value = model.mlfid;
			parameters[1].Value = model.msmid;
			parameters[2].Value = model.ldid;
			parameters[3].Value = model.url;
			parameters[4].Value = model.项目楼栋情况;
			parameters[5].Value = model.座号;
			parameters[6].Value = model.户型;
			parameters[7].Value = model.合同号;
			parameters[8].Value = model.发展商叫价;
			parameters[9].Value = model.楼层;
			parameters[10].Value = model.房号;
			parameters[11].Value = model.用途;
			parameters[12].Value = model.预售查丈建筑面积;
			parameters[13].Value = model.预售查丈户内面积;
			parameters[14].Value = model.预售查丈分摊面积;
			parameters[15].Value = model.竣工查丈户内面积;
			parameters[16].Value = model.竣工查丈分摊面积;
			parameters[17].Value = model.竣工查丈建筑面积;

			int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from ym_web_lf ");
			strSql.Append(" where ");
			MySqlParameter[] parameters = {
			};

			int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public hcrainMvc.Model.ym_web_lf GetModel()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select mlfid,msmid,ldid,url,项目楼栋情况,座号,户型,合同号,发展商叫价,楼层,房号,用途,预售查丈建筑面积,预售查丈户内面积,预售查丈分摊面积,竣工查丈户内面积,竣工查丈分摊面积,竣工查丈建筑面积 from ym_web_lf ");
			strSql.Append(" where ");
			MySqlParameter[] parameters = {
			};

			hcrainMvc.Model.ym_web_lf model=new hcrainMvc.Model.ym_web_lf();
			DataSet ds=DbHelperMySQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public hcrainMvc.Model.ym_web_lf DataRowToModel(DataRow row)
		{
			hcrainMvc.Model.ym_web_lf model=new hcrainMvc.Model.ym_web_lf();
			if (row != null)
			{
					//model.mlfid=row["mlfid"].ToString();
					//model.msmid=row["msmid"].ToString();
					//model.ldid=row["ldid"].ToString();
				if(row["url"]!=null)
				{
					model.url=row["url"].ToString();
				}
				if(row["项目楼栋情况"]!=null)
				{
					model.项目楼栋情况=row["项目楼栋情况"].ToString();
				}
				if(row["座号"]!=null)
				{
					model.座号=row["座号"].ToString();
				}
				if(row["户型"]!=null)
				{
					model.户型=row["户型"].ToString();
				}
				if(row["合同号"]!=null)
				{
					model.合同号=row["合同号"].ToString();
				}
				if(row["发展商叫价"]!=null)
				{
					model.发展商叫价=row["发展商叫价"].ToString();
				}
				if(row["楼层"]!=null)
				{
					model.楼层=row["楼层"].ToString();
				}
				if(row["房号"]!=null)
				{
					model.房号=row["房号"].ToString();
				}
				if(row["用途"]!=null)
				{
					model.用途=row["用途"].ToString();
				}
				if(row["预售查丈建筑面积"]!=null)
				{
					model.预售查丈建筑面积=row["预售查丈建筑面积"].ToString();
				}
				if(row["预售查丈户内面积"]!=null)
				{
					model.预售查丈户内面积=row["预售查丈户内面积"].ToString();
				}
				if(row["预售查丈分摊面积"]!=null)
				{
					model.预售查丈分摊面积=row["预售查丈分摊面积"].ToString();
				}
				if(row["竣工查丈户内面积"]!=null)
				{
					model.竣工查丈户内面积=row["竣工查丈户内面积"].ToString();
				}
				if(row["竣工查丈分摊面积"]!=null)
				{
					model.竣工查丈分摊面积=row["竣工查丈分摊面积"].ToString();
				}
				if(row["竣工查丈建筑面积"]!=null)
				{
					model.竣工查丈建筑面积=row["竣工查丈建筑面积"].ToString();
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select mlfid,msmid,ldid,url,项目楼栋情况,座号,户型,合同号,发展商叫价,楼层,房号,用途,预售查丈建筑面积,预售查丈户内面积,预售查丈分摊面积,竣工查丈户内面积,竣工查丈分摊面积,竣工查丈建筑面积 ");
			strSql.Append(" FROM ym_web_lf ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperMySQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM ym_web_lf ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.id desc");
			}
			strSql.Append(")AS Row, T.*  from ym_web_lf T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperMySQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			MySqlParameter[] parameters = {
					new MySqlParameter("@tblName", MySqlDbType.VarChar, 255),
					new MySqlParameter("@fldName", MySqlDbType.VarChar, 255),
					new MySqlParameter("@PageSize", MySqlDbType.Int32),
					new MySqlParameter("@PageIndex", MySqlDbType.Int32),
					new MySqlParameter("@IsReCount", MySqlDbType.Bit),
					new MySqlParameter("@OrderType", MySqlDbType.Bit),
					new MySqlParameter("@strWhere", MySqlDbType.VarChar,1000),
					};
			parameters[0].Value = "ym_web_lf";
			parameters[1].Value = "id";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperMySQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

